import allure
from selenium.webdriver.common.by import By

from base.base_page import BasePage
# from testcases.user_center.conftest import delete_user, delete_code
from utils.assert_util import assert_compare


class UserPage(BasePage):
    """登录相关"""
    # 用 户 名
    login_account = (By.XPATH, '//*[@id="app"]/div/div[2]/div[4]/div[1]/input')
    # 密     码
    login_password = (By.XPATH, '//*[@id="app"]/div/div[2]/div[4]/div[2]/input')
    # 验证码
    check_code = (By.XPATH, '//*[@id="app"]/div/div[2]/div[4]/div[3]/input')
    # 登录按钮
    login_btn = (By.XPATH, '//*[@id="app"]/div/div[2]/div[4]/button')
    # 用户名为空
    login_account_blank = (By.XPATH, "//p[text()='用户名不能为空']")
    # 登录用户名密码错误信息
    login_account_error = (By.XPATH, "//p[contains(text(),'用户名或密码错误！')]")
    # 登录密码为空错误信息
    login_password_blank = (By.XPATH, "//p[contains(text(),'密码不能为空')]")
    # 验证码不能为空
    check_code_blank = (By.XPATH, "//p[contains(text(),'验证码不能为空')]")
    # 登录成功获取用户名
    success_name = (By.XPATH, '//li[contains(text(),"董倩倩")]')

    def login(self):
        """ 登录，供后续接口调用登录"""
        self.get_url("http://114.116.12.146:8304/#/")
        self.send_keys(self.login_account,"董倩倩")
        self.send_keys(self.login_password, "666666")
        self.send_keys(self.check_code, "jky666666")
        self.click(self.login_btn)